#ifndef _H_C_COROUTINE_GROUP_IMPL_H_
#define _H_C_COROUTINE_GROUP_IMPL_H_

#include "../typedefine.h"
#include "../threadpool.h"
#include "../collection.h"
#include "../promise.h"
#include <memory>
#include <functional>
#include <atomic>
#include "CCoroutineImpl.h"

namespace TB
{
	class CCoroutineGroup;
	class CCoroutineTimerContext;

	class CCoroutineGroupImpl
	{
	public:
		CCoroutineGroupImpl(const std::weak_ptr<CThreadPool>& poThreadPool);
		~CCoroutineGroupImpl();
		void Post(const std::function<void()>& rcbFunction);
		inline UINT32 GetSize() const { return m_dwSize; }

	public:
		std::weak_ptr<CCoroutineGroupImpl> m_poSelf;
		CMPMCQueue<std::function<void()>> m_oTaskQueue;
		CMPMCQueue<std::shared_ptr<CCoroutineImpl>> m_oIdleCoroutineQueue;
		std::weak_ptr<CThreadPool> m_poThreadPool;
		UINT32 m_dwSize = 0;
		std::atomic_uint32_t m_oIdleCount;
	};
}

#endif
